import Vue from 'vue';
import Vuex from 'vuex';
import persistedState from 'vuex-persistedstate';
Vue.use(Vuex);

export default new Vuex.Store({
  state: {
    cot: 0,
  },
  mutations: {
    setCot(state, payload) {
      state.cot = payload;
    },
  },
  actions: {},
  plugins: [
    persistedState({
      storage: window.sessionStorage,
      reducer(state) {
        // state就是vuex的state对象
        return {
          cot: state.cot,
        };
      },
    }),
  ],
});
